package org.dashboard.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.dashboard.bean.AdDictionary;
import org.dashboard.dao.AdDictionaryMapper;
import org.dashboard.service.AdDictionaryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by admin on 2018/9/20.
 */
@Service(interfaceClass = AdDictionaryService.class)
public class AdDictionaryServiceImpl implements AdDictionaryService {
    private static final Logger logger = LoggerFactory.getLogger(AdDictionaryServiceImpl.class);

    @Autowired
    private AdDictionaryMapper adDictionaryMapper;

    @Override
    public int deleteByPrimaryKey(Integer dictionaryId) {
        return 0;
    }

    @Override
    public boolean deleteByPrimaryKeys(ArrayList<Integer> dictionaryIds) {
        for (Integer id : dictionaryIds) {
            adDictionaryMapper.deleteByPrimaryKey(id);
        }
        return true;
    }

    @Override
    public PageInfo selectAdDictionaryPaged(String criteria, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<AdDictionary> adDictionary = adDictionaryMapper.selectAdDictionarySearched(criteria);
        return new PageInfo<>(adDictionary);
    }

    @Override
    public int insert(AdDictionary record) {
        adDictionaryMapper.insert(record);
        return record.getDictionaryId();
    }

    @Override
    public int insertSelective(AdDictionary record) {
        return 0;
    }

    @Override
    public AdDictionary selectByPrimaryKey(Integer dictionaryId) {
        return adDictionaryMapper.selectByPrimaryKey(dictionaryId);
    }

    @Override
    public AdDictionary selectAdDictionaryByCode(String dictionaryCode) {
        return adDictionaryMapper.selectAdDictionaryByCode(dictionaryCode);
    }


    @Override
    public List<AdDictionary> selectadDictionaryTypes(String type) {
        return adDictionaryMapper.selectadDictionaryTypes(type);
    }

    @Override
    public int updateByPrimaryKeySelective(AdDictionary record) {
        return adDictionaryMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(AdDictionary record) {
        return adDictionaryMapper.updateByPrimaryKey(record);
    }
}
